package com.baizhi.service.impl;

import com.baizhi.dao.TriageDao;
import com.baizhi.entity.Triage;
import com.baizhi.service.TriageService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class TriageServiceImpl implements TriageService {
    @Autowired
    private TriageDao triageDao;
    @Override
    public void insertTriage(Triage triage) {
        triageDao.insertTriage(triage);
    }

    @Override
    public void deleteTriage(Integer tid) {
        triageDao.deleteTriage(tid);
    }

    @Override
    @Transactional(readOnly = true)
    public Triage selectById(Integer tid) {
        return triageDao.selectById(tid);
    }

    @Override
    public void updateTriage(Triage triage) {
        triageDao.updateTriage(triage);
    }

    @Override
    @Transactional(readOnly = true)
    public PageInfo<Triage> selectByDepartment(Integer did, Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<Triage> triages = triageDao.selectByDepartment(did);
        PageInfo<Triage> pageInfo = new PageInfo<>(triages);
        return pageInfo;
    }
}
